<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic"
	prefix="logic"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean"
	prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html"
	prefix="html"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://displaytag.sf.net/el" prefix="display-el"%>
<%@ taglib uri="ford-arg/tags" prefix="ft"%>
<%@ taglib uri="http://www.j2ee.ford.com/fjf-ui" prefix="ui"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>

<script type="text/javascript" language="javascript"
	src="./scripts/ajaxSearch.js">
</script>
<script language="JavaScript" src="./scripts/popups.js"></script>
<SCRIPT language="JavaScript" src="./scripts/CalendarPopup.js">
</SCRIPT>


<script language="javascript">
	var cal = new CalendarPopup(); 
	cal.showNavigationDropdowns();
	cal.setMonthNames('<bean:message key="label.month.january"/>',
						'<bean:message key="label.month.february"/>',
						'<bean:message key="label.month.march"/>',
						'<bean:message key="label.month.april"/>',
						'<bean:message key="label.month.may"/>',
						'<bean:message key="label.month.june"/>',
						'<bean:message key="label.month.july"/>',
						'<bean:message key="label.month.august"/>',
						'<bean:message key="label.month.september"/>',
						'<bean:message key="label.month.october"/>',
						'<bean:message key="label.month.november"/>',
						'<bean:message key="label.month.december"/>');
	cal.setDayHeaders('<bean:message key="label.day.sunday.capital"/>',
						'<bean:message key="label.day.monday.capital"/>',
						'<bean:message key="label.day.tuesday.capital"/>',
						'<bean:message key="label.day.wednesday.capital"/>',
						'<bean:message key="label.day.thursday.capital"/>',
						'<bean:message key="label.day.friday.capital"/>',
						'<bean:message key="label.day.saturday.capital"/>');
	cal.setTodayText('<bean:message key="label.today"/>');
	
	
	function createUpdateSupply(){
		document.SupplyForm.action = "SupplyActionCreateUpdate.do";
		document.SupplyForm.operation.value = "createUpdate";
		document.SupplyForm.submit();
	}
	
	
	function deleteSupply(rowNum) {
		if (confirm('<bean:message key="supply.confirmDelete" /> ')) {
			document.SupplyForm.action = "SupplyActionDelete.do";
			document.SupplyForm.operation.value = "delete";
			document.SupplyForm.selectedRowNum.value = rowNum;
		}else{
			return false;
		}
	}
	function findSupply(){
		document.SupplyForm.action = "SupplyActionFind.do";
		document.SupplyForm.operation.value = "find";
		document.SupplyForm.submit();
	}
	
	function editSupply(obj){
		document.SupplyForm.action = "SupplyActionEditSelected.do";
		document.SupplyForm.operation.value = "edit";
		document.SupplyForm.selectedRowNum.value = obj;

	}
	
	function clearFindFilds (){
		document.SupplyForm.action = "SupplyActionCleanFind.do";
		document.SupplyForm.operation.value = "clean";
		document.SupplyForm.submit();
	}
	function clearPanelFilds (){
		document.SupplyForm.action = "SupplyActionCleanPanel.do";
		document.SupplyForm.operation.value = "clean";
		document.SupplyForm.submit();
	}
	
	function moreSupply(obj){
		document.SupplyForm.action = "SupplyPricingPart.do";
		document.SupplyForm.selectedRowNum.value = obj;
	}
	
</script>

<table>
	<tr>
		<td colspan="2">
		<h2><bean:message key="supply.label.title" /></h2>
		</td>
	</tr>
</table>
<br />
<html:form action="/SupplyActionFind">
	<%-- Mantiene el numero de pagina despues del submit --%>
	<ft:saveActivePageNumber />

	<html:hidden property="modePanel" />
	<html:hidden property="operation" />
	<html:hidden property="selectedRowNum" />

	<bean:define id="nameTitle">
		<bean:message key="part.label.tableHeader.description" />
	</bean:define>
	<bean:define id="partTitle">
		<bean:message key="supply.label.table.header.part" />
	</bean:define>
	<bean:define id="currentTitle">
		<bean:message key="supply.label.table.header.current" />
	</bean:define>
	<bean:define id="priceTitle">
		<bean:message key="supply.label.table.header.price" />
	</bean:define>
	<bean:define id="fechaInTitle">
		<bean:message key="supply.label.table.header.dateOut" />
	</bean:define>
	<bean:define id="fechaOutTitle">
		<bean:message key="supply.label.table.header.dateIn" />
	</bean:define>
	<bean:define id="supplierTitle">
		<bean:message key="supply.label.table.header.supplier" />
	</bean:define>
	<bean:define id="actionsTitle">
		<bean:message key="part.label.tableHeader.actions" />
	</bean:define>
	<bean:define id="shareTitle">
		<bean:message key="supply.label.table.header.share" />
	</bean:define>
	<bean:define id="tvmValueTitle">
		<bean:message key="supply.label.table.header.TVMValue" />
	</bean:define>
	<bean:define id="tvmUpdateTitle">
		<bean:message key="supply.label.table.header.TVMupdate" />
	</bean:define>
	<bean:define id="createTitle">
		<bean:message key="supply.label.table.header.creation" />
	</bean:define>
	<bean:define id="uploadTitle">
		<bean:message key="supply.label.table.header.upload" />
	</bean:define>

	<!-- Text by CurrenciPrice -->
	<bean:define id="currentPrice">
		<bean:message key="supply.label.table.header.currentPrice" />
	</bean:define>

	<bean:define id="dateIn">
		<bean:message key="supply.label.table.header.dateIn" />
	</bean:define>

	<bean:define id="dateOut">
		<bean:message key="supply.label.table.header.dateOut" />
	</bean:define>

	<!--  End Titles -->
	<table style="width: 920px;" class="no_border">
		<tr>
			<td class="text_blue_bold align_left" colspan="1">
				<bean:message key="part.label.filter" />
			</td>
		</tr>
		<tr>
			<td class="text_blue_bold align_left" width="5%">
				<bean:message key="part.label.supplier" />
			</td>
			<td class="align_left" width="5%">
				<html:select property="supplierF" styleId="supplierClass">
					<html:option value="-1"><bean:message key="label.allOption" /></html:option>
					<html:options collection="partClassColl" property="value" labelProperty="label" />
				</html:select>
			</td>
			<td class="align_left" colspan="1" width="15%">
				<html:text styleId="supplierCode" property="supplierCodeF" maxlength="6" size="9" />
				<html:button property="" onclick="searchNameSupplier('result','supplierCode','supplierClass');">.&nbsp.&nbsp.</html:button>
				<html:button property="suppdsad" onclick="findSupplierPopup('supplierClass','supplierCode');">&nbsp?&nbsp</html:button>
			</td>
			<td class="text_blue_bold align_left" colspan="3" width="50%">
				<div id="result" title="result" style="display: inline;"></div>
			</td>
			<td class="text_blue_bold align_left" colspan="1" width="12%">
				<bean:message key="supply.label.tvm" />
			</td>
			<td class="align_left" width="13%">
				<html:select property="tvmFindMode" styleId="tvmFindMode">
					<html:option value="-1"><bean:message key="label.allOption" /></html:option>
					<!--html:options collection="tvmModeFindColl" property="value" labelProperty="label" /-->
				</html:select>
			</td>
		</tr>
		<tr>
			<td class="text_blue_bold align_left" width="5%">
				<bean:message key="part.label" />
			</td>
			<td class="align_left" width="5%">
				<html:select property="partCF" styleId="partClass">
					<html:option value="-1"><bean:message key="label.allOption" /></html:option>
					<html:options collection="partClassColl" property="value" labelProperty="label" />
				</html:select>
			</td>
			<td class="text_blue_bold align_left" colspan="2" width="25%">
				<html:text property="partPreCF" maxlength="10" size="9" styleId="partPrefix" />&nbsp;
				<html:text property="partBaseF" maxlength="10" size="9" styleId="partBase" />&nbsp;
				<html:text property="partSufixF" maxlength="10" size="9" styleId="partSuffix" />&nbsp;
				<html:button property="parF" onclick="searchNamePart('partF','partClass','partPrefix','partBase','partSuffix');">.&nbsp.&nbsp.</html:button>
				<html:button property="sada" onclick="findPartPopup('supplierClass','supplierCode','partClass','partPrefix','partBase','partSuffix');">&nbsp?&nbsp</html:button>
			</td>
			<td class="text_blue_bold align_left" colspan="4" width="65%">
				<div id="partF" title="partF" style="display: inline;"></div>
			</td>
		</tr>
		<tr>
			<td class="text_blue_bold align_left" colspan="4" width="43%">
				<bean:message key="supply.label.effDateIn" />&nbsp;
				<html:text styleId="dateInEffStart" property="dateInEffStart" maxlength="10" size="10" /><A name="dateInMinAnchor"> </A><html:button property="calendar" onclick="cal.select(document.SupplyForm.dateInEffStart,'dateInMinAnchor','dd/MM/yyyy'); return false;" styleClass="button_small">...</html:button> 
				<bean:message key="label.and" /> 
				<html:text styleId="dateInEffEnd" property="dateInEffEnd" maxlength="10" size="10" /><A name="dateInMaxAnchor"> </A><html:button property="calendar" onclick="cal.select(document.SupplyForm.dateInEffEnd,'dateInEffEnd','dd/MM/yyyy'); return false;" styleClass="button_small">...</html:button>
			</td>
			<td class="text_blue_bold align_left" colspan="3" width="44%">
				<bean:message key="supply.label.effDateOut" />&nbsp;
				<html:text styleId="dateOutEffStart" property="dateOutEffStart" maxlength="10" size="10" /><A name="dateOutMinAnchor"> </A><html:button property="calendar" onclick="cal.select(document.SupplyForm.dateOutEffStart,'dateInMinAnchor','dd/MM/yyyy'); return false;" styleClass="button_small">...</html:button> 
				<bean:message key="label.and" /> 
				<html:text styleId="dateOutEffEnd" property="dateOutEffEnd" maxlength="10" size="10" /><A name="dateOutMaxAnchor"> </A><html:button property="calendar" onclick="cal.select(document.SupplyForm.dateOutEffEnd,'dateInMinAnchor','dd/MM/yyyy'); return false;" styleClass="button_small">...</html:button>
			</td>
			<td class="align_center" colspan="1" width="13%">
				<html:button property="find" onclick="findSupply();" styleClass="button_small">
					<bean:message key="label.find" />
				</html:button>
				<html:button property="clean" styleClass="button_small" onclick="clearFindFilds();">
					<bean:message key="label.clean" /> 
				</html:button>
			</td>
		</tr>
	</table>
	<br />

	<div class="edit_out align_center" style="width:900px;">
	<div class="edit align_center" style="width: 900px;">
	<table style="width: 900px;" class="no_border">

		<!-- Panel Mode Creation -->
		<logic:equal property="modePanel" value="new" name="SupplyForm">
			<tr>
				<td class="text_blue_bold align_left" width="158"><bean:message
					key="part.label.supplier" /></td>
				<td width="88"><html:select
					property="teess01Supplier.eess01SupplierClassCodeC"
					styleId="supplierClassNew">
					<html:option value="-1">
						<bean:message key="label.allOption" />
					</html:option>
					<html:options collection="partClassCollNew" property="value"
						labelProperty="label" />
				</html:select></td>
				<td class="text_blue_bold align_left">
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <html:text styleId="supplierCodeNew"
					property="teess01Supplier.eess01SupplierCodeC" maxlength="6"
					size="9" /> &nbsp;&nbsp;&nbsp;&nbsp;<html:button property="find"
					onclick="searchNameSupplier('nameSupplierNew','supplierCodeNew','supplierClassNew')">.&nbsp.&nbsp.</html:button>
				<html:button property="button"
					onclick="findSupplierPopup('supplierClassNew','supplierCodeNew');">&nbsp?&nbsp</html:button></td>
				<td class="text_blue_bold" align="left">
				<div id="nameSupplierNew" title="nameSupplierNew" align="left"
					style="display: inline;"></div>
				</td>
				<td><html:button styleClass="button_small" property="update"
					onclick="createUpdateSupply();">
					<bean:message key="label.createUpdate" />
				</html:button></td>
			</tr>
			<tr>
				<td class="text_blue_bold align_left" width="158"><bean:message
					key="part.label" /></td>
				<td width="88"><html:select
					property="teesp01Part.eesp01PartClassCodeC" styleId="partClassNew">
					<html:option value="-1">
						<bean:message key="label.allOption" />
					</html:option>
					<html:options collection="partClassCollNew" property="value"
						labelProperty="label" />
				</html:select></td>
				<td class="align_left">&nbsp&nbsp&nbsp&nbsp&nbsp <html:text
					property="teesp01Part.eesp01PartPrefixCodeC" maxlength="10"
					size="10" styleId="prefijoNew" /> &nbsp&nbsp&nbsp<html:text
					property="teesp01Part.eesp01PartBaseCodeC" maxlength="10" size="10"
					styleId="baseNew" /> &nbsp&nbsp <html:text
					property="teesp01Part.eesp01PartSuffixCodeC" maxlength="10"
					size="10" styleId="sufijoNew" /> &nbsp&nbsp&nbsp <html:button
					property="partN"
					onclick="searchNamePart('partNew','partClassNew','prefijoNew','baseNew','sufijoNew')">.&nbsp.&nbsp.</html:button>
				<html:button property="sdaw"
					onclick="findPartPopup('','','partClassNew','prefijoNew','baseNew','sufijoNew');">&nbsp?&nbsp</html:button>
				</td>
				<td class="text_blue_bold align_left">
				<div id="partNew" align="left" style="display: inline;"></div>
				</td>
				<td><html:button property="clean" styleClass="button_small"
					onclick="clearPanelFilds();">
					<bean:message key="label.clean" />
				</html:button></td>
			</tr>
		</logic:equal>
		<!-- END Panel Mode Creation -->
		<tr>
		</tr>
		<!-- Panel Mode Edit -->
		<logic:equal property="modePanel" value="edit" name="SupplyForm">
			<tr>
				<td class="text_blue_bold align_left" width="158"><bean:message
					key="part.label.supplier" /></td>
				<td width="88"><html:select
					property="teess01Supplier.eess01SupplierClassCodeC" disabled="true">
					<html:option value="-1">
						<bean:message key="label.allOption" />
					</html:option>
					<html:options collection="partClassCollNew" property="value"
						labelProperty="label" />
				</html:select></td>
				<td class="align_left">&nbsp&nbsp&nbsp&nbsp&nbsp <html:text
					styleId="supplierCode"
					property="teess01Supplier.eess01SupplierCodeC" maxlength="6"
					size="9" disabled="true" /> &nbsp&nbsp <html:button property="find"
					onclick="searchNamePartNew()" disabled="true">...</html:button> <html:button
					property="" disabled="true"> ? </html:button></td>
				<td>
				<div id="nameSupplierNew" title="nameSupplierNew"></div>

				</td>

				<td><html:button styleClass="button_small" property="update"
					onclick="createUpdateSupply();">
					<bean:message key="label.createUpdate" />
				</html:button></td>
			</tr>
			<tr>
				<td class="text_blue_bold align_left" width="158"><bean:message
					key="part.label" /></td>
				<td width="88"><html:select
					property="teesp01Part.eesp01PartClassCodeC" disabled="true">
					<html:option value="-1">
						<bean:message key="label.allOption" />
					</html:option>
					<html:options collection="partClassCollNew" property="value"
						labelProperty="label" />
				</html:select></td>
				<td class="align_left">&nbsp&nbsp&nbsp&nbsp <html:text
					property="teesp01Part.eesp01PartPrefixCodeC" maxlength="10"
					size="9" disabled="true" />
				&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <html:text
					property="teesp01Part.eesp01PartBaseCodeC" maxlength="10" size="9"
					disabled="true" /> &nbsp&nbsp&nbsp&nbsp <html:text
					property="teesp01Part.eesp01PartSuffixCodeC" maxlength="10"
					size="9" disabled="true" /> &nbsp&nbsp&nbsp <html:button
					property="" disabled="true">.&nbsp.&nbsp.</html:button> <html:button
					property="" disabled="true">&nbsp?&nbsp</html:button></td>
				<td>
				<div id="partNew"></div>
				</td>
				<td><html:button property="clean" styleClass="button_small"
					onclick="clearPanelFilds();">
					<bean:message key="label.clean" />
				</html:button></td>
			</tr>

		</logic:equal>
		<!-- END Panel Mode Edit -->
		<tr>
			<td class="text_blue_bold align_left" width="158" height="40"><bean:message
				key="supply.label.share" /></td>
			<td class="align_left" height="40"><html:text property="procShereNew"
				maxlength="8" size="9" /></td>
			<td class="text_blue_bold align_left" height="40">&nbsp&nbsp&nbsp&nbsp <bean:message
				key="supply.label.tvm" /> &nbsp&nbsp <html:select
				property="currencyNew">
				<html:option value="-1">-Seleccionar-</html:option>
				<html:options collection="economicMeasure"
					property="eesm01CurrencyCodeC" labelProperty="eesm01CurrencyCodeC" />
			</html:select> &nbsp&nbsp<html:text property="valueTVMNew" maxlength="13" size="9" />
			</td>
		</tr>
	</table>
	</div>
	</div>

	<br />

	<table class="no_border" style="width: 900px;">
		<tr>
			<td><display-el:table class="table1" style="width: 900px;"
				cellpadding="5" uid="supply" pagesize="15"
				name="sessionScope.SupplyForm.supplyS" excludedParams="*"
				requestURI="SupplyActionPaginate.do">
				<display-el:column title="${supplierTitle}" style="width: 12%;"
					class="cell1 text_bold border1_right border1_top align_left"
					headerClass="header border_right">
							${supply.teesp04Supply.teess01Supplier.eess01SupplierClassCodeC}&minus;
							${supply.teesp04Supply.teess01Supplier.eess01SupplierCodeC}&minus;
							${supply.teesp04Supply.teess01Supplier.eess01SupplierNameN}
					</display-el:column>
				<display-el:column title="${partTitle}" style="width: 12%;"
					class="cell1 text_bold border1_right border1_top align_left"
					headerClass="header border_right">
							${supply.teesp04Supply.teesp01Part.eesp01PartClassCodeC}&nbsp;
							${supply.teesp04Supply.teesp01Part.eesp01PartPrefixCodeC}&minus;
							${supply.teesp04Supply.teesp01Part.eesp01PartBaseCodeC}&minus;
							${supply.teesp04Supply.teesp01Part.eesp01PartSuffixCodeC}
				</display-el:column>
				<display-el:column title="${shareTitle}"
					property="teesp04Supply.eesp04SupplySharePercentP"
					style="width: 8%;"
					class="cell1 text_bold border1_right border1_top align_left"
					headerClass="header border_right" />

				<display-el:column title="${tvmValueTitle}"
					property="teesp04Supply.eesp04SupplyTvmAmountA" style="width: 5%;"
					class="cell1 text_bold border1_right border1_top align_center"
					headerClass="header border_right" />


				<display-el:column title="${tvmUpdateTitle}"
					decorator="ar.com.ford.it.fullEconomics.view.displaytag.CostStructureItemColumnDecorator"
					style="width: 10%;"
					class="cell1 text_bold border1_right border1_top align_center"
					headerClass="header border_right">
						
						${supply.teesp04Supply.eesp04LastUpdtTvmUserC}<br />${supply.teesp04Supply.eesp04LastUpdtTvmS}
					</display-el:column>

				<display-el:column title="${createTitle}"
					decorator="ar.com.ford.it.fullEconomics.view.displaytag.CostStructureItemColumnDecorator"
					style="width: 10%;"
					class="cell1 text_bold border1_right border1_top align_left"
					headerClass="header border_right">
					
						${supply.teesp04Supply.eesp04CreateUserC}<br />${supply.teesp04Supply.eesp04CreateS}
					
					</display-el:column>

				<display-el:column title="${uploadTitle}"
					decorator="ar.com.ford.it.fullEconomics.view.displaytag.CostStructureItemColumnDecorator"
					style="width: 8%;"
					class="cell1 text_bold border1_right border1_top align_left"
					headerClass="header border_right">
					
						${supply.teesp04Supply.eesp04LastUpdtUserC}<br />${supply.teesp04Supply.eesp04LastUpdtS}
						
					</display-el:column>

				<display-el:column title="${actionsTitle}" style="width: 6%;"
					class="cell1 text_bold border1_right border1_top align_left"
					headerClass="header border_right">

					<html:image property="" onclick="editSupply(${supply_rowNum});"
						page="/images/edit.gif" style="width:20px" />&nbsp;
							<html:image property="" alt="${delete}"
						onclick="deleteSupply(${supply_rowNum});" page="/images/erase.gif"
						style="width:20px" />&nbsp;
		
					</display-el:column>

				<display-el:column title="${currentPrice}" style="width: 15%;"
					class="cell1 text_bold border1_right border1_top align_center"
					headerClass="header border_right">

							${supply.teesp05Pricing.eesp05CurrencyCodeC.eesm01CurrencyCodeC} &nbsp; ${supply.teesp05Pricing.eesp05PriceAmountA}

					</display-el:column>

				<display-el:column title="${dateIn}"
					property="teesp05Pricing.eesp05PriceEffectiveDateY"
					style="width: 10%;"
					class="cell1 text_bold border1_right border1_top align_center"
					headerClass="header border_right"
					decorator="ar.com.ford.it.fullEconomics.view.displaytag.DateDecorator" />


				<display-el:column title="${dateOut}"
					property="teesp05Pricing.eesp05PriceEndDateY" style="width: 10%;"
					class="cell1 text_bold border1_right border1_top align_center"
					headerClass="header border_right"
					decorator="ar.com.ford.it.fullEconomics.view.displaytag.DateDecorator" />

				<display-el:column title="${actionsTitle}" style="width: 6%;"
					class="cell1 text_bold border1_right border1_top align_left"
					headerClass="header border_right">
					<html:submit styleClass="button"
						onclick="moreSupply(${supply_rowNum});">
						<bean:message key="supply.label.table.more" />
					</html:submit>
				</display-el:column>

			</display-el:table></td>
		</tr>
	</table>
</html:form>
